//
//  BottleDetailController.m
//  Water
//
//  Created by yh on 2018/1/15.
//  Copyright © 2018年 chenguibang. All rights reserved.
//

#import "BottleDetailController.h"
#import <BlocksKit/BlocksKit+UIKit.h>
@interface BottleDetailController ()

@end

@implementation BottleDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setupViews];
}


- (void)setupViews{

    self.amountTextFiled.text = self.bottle.amount ? [NSString stringWithFormat:@"%@",self.bottle.amount] : @"";
    UIBarButtonItem *editBtn = [[UIBarButtonItem alloc]bk_initWithBarButtonSystemItem:UIBarButtonSystemItemSave handler:^(id sender) {
        if(!self.bottle){
            self.bottle = [[BottleItem alloc]init];
        }
        
        self.bottle.amount = @([self.amountTextFiled.text floatValue]);
        if (self.save) {
            self.save(self.bottle);
        }
        [self.navigationController popViewControllerAnimated:YES];
    }];
    self.navigationItem.rightBarButtonItem = editBtn;
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
